package cn.yunyichina.provider.base.service.impl;

import cn.yunyichina.provider.base.dao.DictionaryDao;
import cn.yunyichina.provider.base.entity.*;
import cn.yunyichina.provider.base.entity.Dictionary;
import cn.yunyichina.provider.base.vo.DeptUserRequest;
import cn.yunyichina.provider.iface.entity.base.DeptUserResponse;
import cn.yunyichina.provider.iface.entity.common.ResponseObject;
import cn.yunyichina.utils.convert.JsonUtils;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.*;

/**
 * Created by Administrator on 2018/3/7.
 */
@Service
public class DictionaryServiceImpl {

    @Autowired
    private DictionaryDao dictionaryDao;

    /**
     * 字典查询接口 yyt.base.dictionary.list
     * 按字典编码查询
     * @param data
     * @return
     */
    public ResponseObject listDictionary(String data) {
        ResponseObject response = new ResponseObject();
        Dictionary requestVo =  JsonUtils.parseObject(data, Dictionary.class);

        if(requestVo == null || StringUtils.isBlank(requestVo.getDicCode())) {
            response.setResultCodeAndMessage("1201", "dic_code不能为空");
            return response;
        }
        List<Dictionary> list = dictionaryDao.selectByDicCode(requestVo.getDicCode());

        response.setResultObject(list);
        response.setResultCodeAndMessage("0","成功");

        return response;
    }
}
